import unittest
from time import sleep

from common.functions import save_screenshot
from common.decorators import mkdir_classname, log4gs
from common.settings import TAG
from pages_example.camListPage import CamListPage


@log4gs
@mkdir_classname(TAG)
class CamListTest(unittest.TestCase):
    """摄像机管理功能测试"""
    @classmethod
    def setUpClass(cls):
        cls.log.info('=' * 30 + "开始摄像机功能测试({})".format(__class__.__name__) + '=' * 30)
        cls.page = CamListPage('/DevManage/camManage')

    @classmethod
    def tearDownClass(cls):
        cls.log.info('=' * 30 + "结束摄像机管理功能测试({})".format(__class__.__name__) + '=' * 30)
        cls.page.driver.quit()

    def setUp(self):
        self.log.info('>>>>>开始执行用例：{} {}'.format(self.id(), self.shortDescription()))

    def tearDown(self):
        self.log.info('<<<<<结束执行用例：{} {}'.format(self.id(), self.shortDescription()))

    @unittest.skip
    def test_abc1(self):
        """举例：搜索里面的区域选择器、增加摄像机里面的区域选择器"""
        self.page.searchTools.region.click()
        self.page.searchTools.region_selector.select("广东省-广州市-白云区")
        self.page.searchTools.region.clear()
        sleep(1)

        self.page.searchTools.region.click()
        self.page.searchTools.region_selector.select("上海-上海市-奉贤区")
        self.page.searchTools.region.clear()
        sleep(1)

        self.page.table.add_btn.click()
        sleep(1)

        self.page.add_cam.region.click()
        self.page.add_cam.region_selector.select("云南省-玉溪市-澄江县")
        self.page.add_cam.region.clear()
        sleep(1)

        self.page.add_cam.region.click()
        self.page.add_cam.region_selector.select("广西壮族自治区-南宁市-青秀区")
        self.page.add_cam.region.clear()
        sleep(1)

        self.page.add_cam.region.click()
        self.page.add_cam.region_selector.select("上海-上海市-奉贤区")
        self.page.add_cam.region.clear()
        sleep(1)

        self.page.add_cam.region.click()
        self.page.add_cam.region_selector.select("广东省-广州市-白云区")
        self.page.add_cam.region.clear()
        sleep(1)

        self.page.add_cam.region.click()
        self.page.add_cam.region_selector.select("澳门特别行政区-氹仔岛-嘉模堂区")
        sleep(3)

    def test_abc2(self):
        """弹窗的导入按钮"""
        self.page.table.upload.click()
        sleep(1)
        self.page.upload_window.upload.click()
        sleep(3)


if __name__ == '__main__':
    unittest.main()